﻿namespace TanzimSaqib.NoBrainer.Sample.Tests
{
    using System;
    using DataAccess;
    using Controllers;
    using System.Collections.Generic;
    using Xunit;
    using Moq;

    public class BlogControllerTest
    {
        private readonly Blog _Blog;
        private readonly IBlogController _Controller;
        private readonly Mock<ISingleRepository> _MockRepository = new Mock<ISingleRepository>();

        public BlogControllerTest()
        {
            _Blog = new Blog
                        {
                            ID = 1,
                            UserId = new Guid("419C54A4-0E7B-4566-B2C3-39EE5A0C52D9")
                        };

            _Controller = new BlogController(_MockRepository.Object);
        }

        [Fact]
        public void GivenAnExistingBlog_ManagePostsLoad_ReturnAListOfBlogPosts()
        {
            _MockRepository.Setup(r => r.GetPosts(It.IsAny<Blog>()))
                .Returns(It.IsAny<IEnumerable<Post>>())
                .Verifiable();

            _Controller.ManagePostsLoad(_Blog);

            _MockRepository.Verify(r => r.GetPosts(It.IsAny<Blog>()), Times.Once());
            _MockRepository.VerifyAll();
        }
    }
}
